package com.adb.dao;

import android.database.sqlite.SQLiteDatabase;

public class SqlForDBCreate {

	public static String dataEsay[] = new String[] {
			// "-------------------------------------初级------------------------------          ",
			// "苍井空（简单第一关）                                                             ",
			"268745310714936508503028674857261400320570861146803207931082745402350106685417032",
			// "268745310714936528503128674857261403320574861146803257931682745472350186685417032",
			// "吉泽明步（简单第二关）                                                           ",
			"006350402400007010007090003800601000040000907002000300023010504094700000100900020",
			// "小泽玛利亚（简单第四关）                                                         ",
			"851000009000260700000501003000000084028930005009000060600014000300780000170020530",
			// "北原多香子（简单第五关）                                                         ",
			"005130200010800090490700000603000700500600030070001000000200481100074000200000070",
			// "爱田由（简单第九关）                                                             ",
			"070000209000801000050000000060970051400000980000500002803257040500190708120400000",
			// "小泉彩（普通第一关）                                                             ",
			"100400620050700004000200070000028040037000000600000000000300105200010000400060237",
			// "七(4001)                                                                         ",
			"908000306020813090000090000400781009080050020500234008000060000030948070209000603",
			// "八(4002)                                                                         ",
			"900406005263080914005000600000309000030608090006000800070000040409030507600704008",
			// "九(4003)                                                                         ",
			"008000400000501000700090008080204060050010020302609104009060700140000035000308000",
			// "(4004)                                                                           ",
			"000070000403012008000600100100400307020030050600700209000100800208057006000040000",
			// "十一                                                                             ",
			"000000945006000000520103807090310000003080100000046020705208019000000300861000000",

			"080001600070400021500396000204050130008907500057030900000563009310002050005800040",

			"065000300200067900040300001006050004000402000700080100600004010008570006001000830",

			"900278100001030249003000000030800000007000500000004030000000300578040900004516007",

			"000000004028750030031002000650237000000090000000681059000900860090024310500000000",
			// "十六                                                                             ",
			"645900003700000000030006804000050039100307002420090000204800090000000005500009416",

			"000090030000860120000342860007000205008000600201000400035276000016084000020050000",

			"000000003000590400820004605006005200500106009001200300108900047007083000200000000",

			"000904000092563810600000005500408003070000050200709001700000004014385760000207000",

			"206907000095000630000030200050040001000302000400070060001060000079000180000108409",

			// "二十一                                                                           ",
			"002007003060084020000000040900170000710506038000039006020000000050260070100700800",

			"070900010009400000050008006310000800904103205006000073100600050000004900040002030",

			"000400260030800070540200000014000300903000401006000750000006035020008090067005000",

			"076000310900050004005608900061070830000000000089010540002307100600090003098000260",

			"002040800950000041000203000060905010700000004030604050000706000470000035006030100",

	};

	public static String dataExpert[] = new String[] {
			// "-------------------------------------专家-------------------------------------   ",
			// "武藤兰                                                                           ",
			"100002005000105900300000240000003709000090604000200850000376000900008002000900037",
			// "泽井牙衣（普通第二关）                                                           ",
			"008100060000760500040090000030600058700000004500000170100000203000083000000041000",
			// "西野翔（困难第一关）                                                             ",
			"200030006000700300060001000500020040070360800000000000037600000000040025000000000",

			"804509601091000740000030000700408006003000900400903002000090000076000580902807103",

			"004300280920086050600000001040000009010020070300000040800000002060250013095003700",
			// "一零六                                                                           ",
			"000000010000097604073400500200030040004916200050080000009002850402560000030000000",

			"004700001601000580000095300060040010408000702010050090006510000089000203700002100",

			"007238000060700050000400002900000867100000003648000005700003000020005030000174900",

			"095008000002006700040000005050020007060050020400070080200000040006100300000300250",
			// "-----------4010                                                                  ",
			"000000000005080100070304020207030604040708030009000200090802060401000702000647000",
			// "一十一4011                                                                       ",
			"001000700023601450005000200000804000010070030486020197070000020000090000050137040",

			"600090180030006700700000020500024000000603000000980007020000008009100070087050009",

			"570000000000013000400007580600000030000984000020000007081200009000130000000000054",

			"045000000000020790006030004000002530010000040059600000400010300067090000000000480",
			// "一十六                                                                           ",
			"500000900000200001000130520020000007009406300400000010054069000900001000006000003",

			"001040200000703000305000801020000080000609000090000050506000103000501000008060400",

			"000006500827000001000027000008600000510000067000001200000790000600000829004500000",

			"000002500304680000100000600051040000070060040000010780007000009000028103008700000",

			"000360700080000020000907001000030100036000480005070000700209000050000060002046000",
			// 二十一 ",
			"080007050090810000065200000004600000003000200000008700000004890000056030070900040",

			"402000708090002060700800005080030900000701000001080030900007004020300070503000806",

			"800000503010605090200007000045070020000509000080030150000900001060203080503000004",

			"900005026200000100080120000300204700009000600008503009000081060006000003830600007",

			"300045000008000000050010097030000150540090062082000040190020080000000900000970005",

			"001009006005480090000000080030005401070000030106300050060000000050093200300500600",

	};

	public static String dataMaster[] = new String[] {
			// -------------------------------------大师-------------------------------------
			// ",
			// 松岛枫 8001 ",
			"000040600008000010024060700800509060091020005500703090087030500003000040000090800",

			"010008407950000000008010000082000000700406008000000620000050700000000082503200010",

			"000890020009005007050000300093500100000107000001006840008000060900600400010028000",

			"080790000000002090003008450008000001096000370300000200032500900040800000000064020",

			"100000004245000708030500000900003100000807000007600002000009040402000653300000009",

			// 六 ",
			"001400000000078601000050900080000023013000560950000070005040000309180000000007300",

			"030000740000000080000485620200009000060104030000800009096731000020000000017000060",

			"000050000009006800057000240080904000200060003000308010048000350001400700000090000",

			"000000008003970000600030020800200070079000240010007009060050004000042900500000000",

			"000057080300000000002900400200809300400000007007406008006002700000000005090310000",

			// 一一 ",
			"069010030007900000000840006000300100530070048002008000600023000000001500010080470",

			"260709000000000000018230000100000054500070003940000006000096840000000000000804019",

			"104050060000000087000703000052004000309070804000500630000907000290000000030080701",

			"000001200500034000010070960003007000240060097000400100058010040000790005006800000",

			"800310000054000000200000706030725490000000000087439060408000001000000820000097004",

			// 一六 ",
			"600130000800000060007050300300000000516090274000000005009010800020000003000029001",

			"340002075050000040000800200000600094000209000490008000009007000030000050270900013",

			"000000300013005708700301000002006000068000920000100500000208003804600290007000000",

			"070680050000000001409507000560000340000000000034000017000703804300000000090015030",

			"040700000920000607830005400010003000000201000000500040004900071305000094000008060",

			// 二十一 ",
			"700300450000007180804000000200005030000209000050600007000000508071800000082001006",

			"000530080001004000300060070040200036002000500830007010090050008000700900020091000",

			"005702003006100000000000100000090047604000901210030000008000000000005400900204700",

			"001000000600023090302700045000960000030000010000015000540002701070580003000000900",

			"001000600059002000400006002000870010200090007040053000800500006000100790004000500",

	};

	public static void iniDatabase(SQLiteDatabase db) {
		db.beginTransaction();// 显示调用事务,提高插入性能,否则每次插入都会自动开启事务,关闭事务
		try {
			System.out.println("create database begin==================");
			ini_gamedata(db);
			iniTable_GameDratf(db);
			db.setTransactionSuccessful();
			System.out.println("create database success==================");
		} catch (Exception e) {
			// process it
			e.printStackTrace();
		} finally {
			// end a transaction
			db.endTransaction();
		}
	}

	public static void ini_gamedata(SQLiteDatabase db) {
		db.execSQL("DROP TABLE IF EXISTS gamedata");

		StringBuilder _sql = new StringBuilder();
		_sql.append("CREATE TABLE IF NOT EXISTS gamedata (");
		_sql.append(" id INTEGER PRIMARY KEY AUTOINCREMENT,");
		_sql.append(" av_id INTEGER,");
		_sql.append(" data_initial TEXT,");
		_sql.append(" data_ing TEXT,");
		_sql.append(" data_finish TEXT,");
		_sql.append(" state INTEGER,"); // 状态,0:未完成,1:已完成
		_sql.append(" grade INTEGER,");
		_sql.append(" time_keeping INTEGER,");
		_sql.append(" time_best INTEGER ) ");
		db.execSQL(_sql.toString());

		// 初级
		for (int l = 0; l < dataEsay.length; l++) {
			StringBuffer sb = new StringBuffer();
			sb.append("insert into gamedata(av_id,data_initial,data_ing,data_finish,time_keeping,time_best,grade,state) ");
			sb.append(" values(").append(l + 1).append(",'")
					.append(dataEsay[l]).append("','','',0,0,1,0)");
			db.execSQL(sb.toString());
		}
		// 专家
		for (int l = 0; l < dataExpert.length; l++) {
			StringBuffer sb = new StringBuffer();
			sb.append("insert into gamedata(av_id,data_initial,data_ing,data_finish,time_keeping,time_best,grade,state) ");
			sb.append(" values(").append(l + 101).append(",'")
					.append(dataExpert[l]).append("','','',0,0,2,0)");
			db.execSQL(sb.toString());
		}
		// 大师
		for (int l = 0; l < dataMaster.length; l++) {
			StringBuffer sb = new StringBuffer();
			sb.append("insert into gamedata(av_id,data_initial,data_ing,data_finish,time_keeping,time_best,grade,state) ");
			sb.append(" values(").append(l + 201).append(",'")
					.append(dataMaster[l]).append("','','',0,0,3,0)");
			db.execSQL(sb.toString());
		}

	}

	public static void iniTable_GameDratf(SQLiteDatabase db) {
		db.execSQL("DROP TABLE IF EXISTS GameDraft");

		StringBuilder _sql = new StringBuilder();
		_sql.append("CREATE TABLE IF NOT EXISTS GameDraft (");
		_sql.append(" id INTEGER PRIMARY KEY AUTOINCREMENT,");
		_sql.append(" avID INTEGER,");// avID号
		_sql.append(" num INTEGER,");// 81个数中的序号
		_sql.append(" draft TEXT ) ");// 草稿
		db.execSQL(_sql.toString());
	}

}
